<template>
  <div id="print_area" v-loading="loading">
	<BottomTabs v-if="detailInfo.metadataJson" @currentTab="currentTab" :type="type" :detailType = "detailType" :nowRowData="detailInfo" @refresh="refresh"></BottomTabs>
	<!-- 需要调用matt导出 -->
      <!-- <BottomTabs v-if="needExport&&detailInfo.metadataJson&&!loading" @currentTab="currentTab" :type="type" :nowRowData="detailInfo" @refresh="refresh"></BottomTabs> -->
	  <!-- 不 需要调用matt导出 -->
	  <!-- <BottomTabs1 v-if="!needExport&&detailInfo.metadataJson&&!loading" @currentTab="currentTab" :type="type" :nowRowData="detailInfo" @refresh="refresh"></BottomTabs1> -->
  </div>
</template>

<script setup lang="ts">
import DetailPage from '@/views/aplid/DetailPage/index.vue'
import BottomTabs from './bottomTabs/index.vue'
import BottomTabs1 from '@/views/governmentAffairs/overallTask/detailPart/underSubInfo.vue'
import Comments from './comments/index.vue'
import { printHtml } from '@/utils/print'
import apiMod from '@/apiMod/index'
import { getStore } from '@/utils/store'

let title = ref('数据统计')
let loading = ref(false)
let props = defineProps({
    nowRowData:{
        type:Object,
        defalut:()=>({})
    },
    type:{
      type:String,
      defalut:'self' //self本级详情，sub子级详情
    },
	detailType:{
      type:String,
      defalut:'self' //self本级详情，sub子级详情
    },
	needExport:{
		type:Boolean,
      	defalut:true
	}

}) 

provide('subDetailType',props.type)
let defineConfig = {
  label: '基础信息',
	prop: 'base0',
	inline: false,
	showBtn: false,
	labelPosition: 'left',
  labelWidth:"200px",
	column:[
	{
		label: '总任务名称',
		type: 'input',
		prop: 'taskName',
		span: 24,
	},
	{
		label: '描述',
		type: 'input',
		prop: 'taskIntro',
		span: 24,
	},
	{
		label: '开始时间',
		type: 'date',
		format: 'YYYY年MM月DD',
		valueFormat: 'YYYY-MM-DD',
		prop: 'startTime',
		span: 24,
	},
	{
		label: '结束时间',
		type: 'date',
		format: 'YYYY年MM月DD',
		valueFormat: 'YYYY-MM-DD',
		prop: 'endTime',
		span: 24,
	},
	{
		label: '紧急程度',
		type: 'select',
		defaultValue: '0',
		prop: 'emergencyDegree',
		propName: 'emergencyDegreeLabel',
		dicData: [
			{ label: '普通', value: '0' },
			{ label: '紧急', value: '1' },
		],
		span: 24,
	},
	{
		label: '备注',
		type: 'textarea',
		prop: 'remark',
		span: 24,
	},
	{
		label: '附件',
		type: 'upload',
		prop: 'taskAttachment',
		span: 24,
	},
]
}

let exportShow = ref(false)
const currentTab = (activeName) =>{
  if(activeName=='taskContent'){
    exportShow.value = true
  }else{
    exportShow.value = false
  }
}
// 通过id获取详情
let detailInfo:any = ref({})
const getInfoData = async(id) =>{
	loading.value = true
	let res = await apiMod.view_zwglTaskInfo_view(id)
	if(res.code==0){
		detailInfo.value = res.data
		loading.value = false
	}else{
		loading.value = false
	}
}
// getInfoData(props.nowRowData.primaryKey||props.nowRowData.id)

onMounted(()=>{
	detailInfo.value = props.nowRowData
})
const refresh = () =>{
	console.log('处理了')
	getInfoData(props.nowRowData.id)
}
// 获取当前的区域id
let userInfo = getStore('userInfo')
let getParentPath = () => {
	// 拿到上一级
	const level = ['authProvince', 'authCity', 'authArea', 'authStreet', 'authCommunity']
	let list = level.map((el) => {
		return userInfo[el]
	})
	list = list.filter(Boolean)
	let parentPath = ''
	let myAreaId = ''
	let grandPath = ''
	if (list.length > 1) {
		myAreaId = list[list.length - 1]
		if(list.length >= 2){
			parentPath = list[list.length - 2]
		}
		if(list.length >= 3){
			grandPath = list[list.length - 3]
		}
	} else if (list.length == 1) {
		parentPath = list[0]
		myAreaId = list[0]
		grandPath = list[0]
	}
	return {
		myAreaId,
		parentPath,
		grandPath,
		length:list.length
	}
}
let GetParentPath:any = getParentPath()
provide('infoArea',{myAreaId:GetParentPath.myAreaId,parentPath:GetParentPath.parentPath,grandPath:GetParentPath.grandPath,length:GetParentPath.length})


</script>
<style scoped lang="scss">
.title_part{
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    margin-bottom:20px;
}
.tag_part{
    padding: 2px 10px;
    box-sizing: border-box;
    border-radius: 16px;
    background-color: red;
}
.info_active{
  display: flex;
  flex-direction: row;
  justify-content: space-between;
}
</style>